package com.lagou.servlet;

import server.http.HttpProtocolUtil;
import server.http.HttpServlet;
import server.http.Request;
import server.http.Response;

import java.io.IOException;

/**
 * @author caiwei
 * @date 2020-10-12 12:49
 */
public class LagouServlet extends HttpServlet {
    @Override
    public void doGet(Request request, Response response) {
        String content = "<h1>lagouServlet get "+request.getContext().getContextName()+"</h1>";
        try {
            response.write(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String content = "<h1>lagouServlet get "+request.getContext().getContextName()+"</h1>";
        try {
            response.write(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
